package com.zyx.config;

import lombok.*;
import org.apache.commons.lang3.StringUtils;
import org.springframework.boot.context.properties.ConfigurationProperties;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>配置属性类，用于封装接口文档相关属性，从配置文件读取信息封装成当前对象
 *
 * @author Yaxi.Zhang
 * @since 2022/10/6 17:02
 */
@Data
@ConfigurationProperties(prefix = "zyx.swagger")
public class SwaggerProperties {
    private String title = "在线文档"; // 标题
    private String group = ""; // 自定义组名
    private String description = "在线文档"; // 描述
    private String version = "1.0"; //版本
    private Contact contact = new Contact(); // 联系人
    private String basePackage = ""; // swagger会解析的包路径
    private List<String> basePath = new ArrayList<>(); // swagger会解析的url规则
    private List<String> excludePath = new ArrayList<>();// 在basePath基础上需要排除的url规则
    private Map<String, SwaggerProperties> docket = new LinkedHashMap<>(); // 分组文档

    public String getGroup() {
        if (StringUtils.isEmpty(group)) {
            return title;
        }
        return group;
    }

    @Data
    public static class Contact {
        private String name = "zyx"; //联系人
        private String url = "http://www.zyx.com"; //联系人url
        private String email = "zyx@gmail.com"; //联系人email
    }

}
